# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=django
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=4.2.4
pkgrel=1
pkgdesc="A high-level Python Web framework that encourages rapid development and clean design (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url='https://www.djangoproject.com/'
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-asgiref"
         "${MINGW_PACKAGE_PREFIX}-python-pytz"
         "${MINGW_PACKAGE_PREFIX}-python-sqlparse"
         "${MINGW_PACKAGE_PREFIX}-python-tzdata")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-psycopg2: for PostgreSQL backend"
            "${MINGW_PACKAGE_PREFIX}-python-bcrypt: for bcrypt support"
            "${MINGW_PACKAGE_PREFIX}-python-argon2_cffi: for Argon2 support")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-bcrypt"
             "${MINGW_PACKAGE_PREFIX}-python-argon2_cffi"
             "${MINGW_PACKAGE_PREFIX}-python-psycopg2"
             "${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
options=('!strip')
source=(#"Django-${pkgver}.tar.gz"::"https://www.djangoproject.com/download/${pkgver}/tarball/"
        "${_realname}-${pkgver}.tar.gz"::https://github.com/django/django/archive/${pkgver}.tar.gz)
sha512sums=('dde26740d0a3896e1226cd7df437fa0c82943491843bf72eab1cef09e04f0dda7db05e7f562a709d104c144d134d7da4394b1185ceed19d04915b08cead7a965')
noextract=(${_realname}-${pkgver}.tar.gz)

prepare() {
  tar -xzf ${srcdir}/${_realname}-${pkgver}.tar.gz -C ${srcdir} || true
}

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
